package com.example.shellcollector.database;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.example.shellcollector.Entity.AppDailyUsage;
import com.example.shellcollector.Entity.AppUsageAggregate;

import java.util.List;

@Dao
public interface AppDailyUsageDao {
    @Query("select (count(id)) from app_daily_usage where app_id = :appId and date = :date")
    boolean isAppDailyUsageExists(int appId, long date);

    @Insert
    void insertAll(List<AppDailyUsage> appDailyUsages);

    @Query("select app_id, sum(total_running_time) as total, min(first_running_time) as first, max(last_running_time) as last, sum(launch_count) as count from app_daily_usage group by app_id")
    List<AppUsageAggregate> getAppUsageAggregates();
}
